var applyStatusMap = {
	"00":"待审核",
	"01":"审核通过",
	"99":"审核不通过"
};
applyStatusMap["00"];


var basePath = $('#basePath').val();	

function requestResource(resourceId){
        var url = basePath+"/resource/find/"+resourceId;
		request(url, "GET",null,function(result) {
		if (result.code = 200) {
			var resourceObject = result.result;
			initResource(resourceObject);
		} else{
			console.log("获取数据失败");
		}
   });
}

function requestResourceApplyList(resourceId){
        var url = basePath+"/resource/find/applyList/"+resourceId;
		requestHasBefore(url, "GET", null, function(){
			$('#applyList').empty();
		},function(result) {
		if (result.code = 200) {
			var applyList = result.result;
			initApplyList(applyList);
		} else{
			console.log("获取数据失败");
		}
   });
}

function initResource(resourceObject){
		//获取资源详情
	$('#publishUserAvatar').attr('src',basePath+'/'+resourceObject.publishUserAvatar);
	$('#resourceName').text(resourceObject.resourceName);
	
	$('#resourceName1').text(resourceObject.resourceName);
	$('#publishUserName').text(resourceObject.publishUserName);
	$('#createTime').text(formatDate(resourceObject.createTime));
	$('#publishDeptName').text(resourceObject.publishDeptName);
	$('#typeName').text(resourceObject.typeName);
	$('#content').text(resourceObject.content);
	var postTags = '';
	if(null != resourceObject.label){
		var tags = resourceObject.label.split(',');
		$.each(tags, function(i,one){
			postTags = postTags + '<a href="#"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">'+ one +'</font></font></a>';
		});
	}
	$('#lables').html(postTags);
	$('#browseNum').text(resourceObject.browseNum);
	$('#commentNum').text(resourceObject.commentNum);
	$('#storeNum').text(resourceObject.storeNum);
}

function initApplyList(applyList){
	$('#applyList').empty();
	debugger;
	/*var applyList = [{
		publishUserAvatar:'/profile/avatar/2021/01/12/a6fb58df-698d-4bd8-a5bd-e02a121c02bc.png',
		applyUserName:'杨浩',
		status:'00',
		applyRemark:'1111111111111111111111111',
		applyTime:'2020-12-11 23:40:22'
	}];*/
	
	$.each(applyList, function(i,one){
		var bid = '<div class="bid"><div class="bid__head">';
		var img = '<a href="#" class="bid__head-img"><img src="' + basePath+'/'+ one.publishUserAvatar+'" alt=""></a>';
		bid = bid + img + '<div class="bid__head-title">';
		var userName = '<h5><a href="#"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">' + one.applyUserName+'</font></font></a></h5>';
		var userType= '<p><i class="icon ion-ios-navigate"></i><span><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">' +  applyStatusMap[one.status]+'</font></font></span></p>';
		bid = bid + userName + userType + '</div></div>';
		var bid__price = '<div class="bid__price"><span><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">'+one.applyRemark+'</font></font></span>';
		bid__price = bid__price + '<p><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">' + formatDate(one.applyTime) + '</font></font></p></div>';
		bid = bid + bid__price + '</div>';
		$('#applyList').append(bid);
	});
}

$(document).ready(function() {
	$('input[maxlength]').maxlength();
	var resourceId = $('#resourceId').val();
	requestResource(resourceId);
	requestResourceApplyList(resourceId);
	
	/*var resourceObject = {
		publishUserAvatar:basePath+'/profile/avatar/2021/01/12/a6fb58df-698d-4bd8-a5bd-e02a121c02bc.png',
	    resourceName:'测试发布',
        publishUserName:'haoyu',
        createTime:'2020-12-11 23:40:22',
        publishDeptName:'林岳科技',
        typeName:'机械',
        content:'众包指的是一个公司或机构把过去由员工执行的工作任务，以自由自愿的形式外包给非特定的（而且通常是大型的）大众志愿者的做法。（就是通过网络做产品的开发需求调研，以用户的真实使用感受为出发点）。众包的任务通常是由个人来承担，但如果涉及到需要多人协作完成的任务，也有可能以依靠开源的个体生产的形式出现。在美国《连线》杂志2006年的6月刊上，该杂志的记者Jeff Howe首次推出了众包的概念，不过，从提出时间看美国人提出的众包比2005年在中国诞生的威客晚了一年。',
        label:'自由,机械,众包',
        browseNum:1290,
        commentNum:2,
       storeNum:125
	};*/

	

	
	
});


